{% extends "base.html" %}
{% block content %}
<h1>Static variables</h1>
<p>
  This page shows how to define a static variable, for instance
  <code>site</code> in <i>"Welcome on site <b>{{ site }}</b>"</i>
</p>
<p>
  Then, the <a href="/welcome">welcome view</a> only has one variable
  in its template. You will find in the code how to define and how to
  override it. The first place is in the class itself, with the
  dictionary <code>defaults</code>. In second place, you may also
  define an instance var... as does the link in the next paragraph...
</p>
<p>Go to <a href="/other">other page</a> to see same view in action with other var</p>
<div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">obviews.views</span> <span class="kn">import</span> <span class="n">View</span><span class="p">,</span> <span class="n">FormView</span>

<span class="c"># Adding a static variables in context, in *class* or in *instance*</span>
<span class="c"># Overriding the first with the second</span>
<span class="k">class</span> <span class="nc">EnrichedView</span><span class="p">(</span><span class="n">View</span><span class="p">):</span>
    <span class="n">template_name</span> <span class="o">=</span> <span class="s">&quot;welcome.html&quot;</span>
    <span class="n">defaults</span> <span class="o">=</span> <span class="p">{</span><span class="s">&quot;site&quot;</span><span class="p">:</span> <span class="s">&quot;ObViews&quot;</span><span class="p">}</span>

<span class="n">urlpatterns</span> <span class="o">=</span> <span class="n">patterns</span><span class="p">(</span><span class="s">&#39;&#39;</span><span class="p">,</span>
    <span class="p">(</span><span class="s">&#39;^welcome/$&#39;</span><span class="p">,</span> <span class="n">EnrichedView</span><span class="p">()),</span>
    <span class="p">(</span><span class="s">&#39;^other/$&#39;</span><span class="p">,</span> <span class="n">EnrichedView</span><span class="p">(</span><span class="n">site</span><span class="o">=</span><span class="s">&quot;OtherPlace.com&quot;</span><span class="p">)),</span>
<span class="p">)</span>

</pre></div>

<p>
  You will certainly note that both variables are static... defined
  once for all in code. The <strong>next example</strong> demonstrate how to <a
  href="/hello/myVar/">use vars in URLs</a>
</p>
{% endblock %}
